// 云函数入口文件
const cloud = require('wx-server-sdk');

cloud.init({
  env: 'boyi-5g77xpkp0aa0181c'
});

// 云函数入口函数
exports.main = async (event, context) => {

  const wxContext = cloud.getWXContext();

  const db = cloud.database();
  var household;
  console.log(db);
  db.collection('householdInfo').get().then(res => {
    console.log(res.data);
    household = res.data;
  });
  // db.collection('householdInfo').get({
  //   success: function(res) {
  //     // res.data 是一个包含集合中有权限访问的所有记录的数据，不超过 20 条
  //     console.log(res.data)
  //     household = res.data;
  //   }
  // });
  var result = {};
  var data = {};
  data.user = household;
  result.data = data;
  return result;
}